<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>已选中机构</title>


    <!-- Expand styles -->
    <link href="../css/app/app.css" rel="stylesheet">
    <link href="../css/app/default.css" rel="stylesheet">
    <link href="../css/mui/mui.css" rel="stylesheet">


</head>

<body>

    <!-- header -->
    <div>

        <div class="margin-b-20">
            <div class="widget-default widget-body px-border-l margin-b-1">
                <span class="black font-15 font-weight">已选中的机构</span>
            </div>
            <div id="yiXuanZhong">

            </div>


        </div>
        <div class="margin-b-10">
            <div class="widget-default widget-body px-border-l margin-b-1">
                <span class="black font-15 font-weight">已淘汰的机构</span>
            </div>
            <div id="pullrefresh" class="mui-content mui-scroll-wrapper " style="margin-top: 276px;">
                <div class="mui-scroll">
                    <div class="trade-list">

                    </div>
                </div>
            </div>
        </div>

    </div>

    <div id="sheet1" class="mui-popover mui-popover-bottom mui-popover-action ">
        <!-- 可选择菜单 -->
        <ul class="mui-table-view">
            <li class="mui-table-view-cell" onclick="callPhone()">
                <a href="#">拨打 <yang id="connectPhone"></yang></a>
            </li>
        </ul>
        <!-- 取消菜单 -->
        <ul class="mui-table-view">
            <li class="mui-table-view-cell">
                <a href="#sheet1"><b>取消</b></a>
            </li>
        </ul>
    </div>

    <script src="../js/dsbridge.js"></script>
    <script src="../js/jquery.js"></script>
    <script src="../js/mui/mui.js"></script>
    <script src="../js/layer.js"></script>
    <script src="../js/mui/mui.picker.min.js"></script>
    <script src="../js/app/app-base.js"></script>
    <script src="../js/app/app-url.js"></script>
    <script src="../js/app/app-ajax.js"></script>
    <script>
        var page = 1;
        var limit = 10;
        var index = 0;
        var id = localStorage.getItem("baojia-result-id");
        var all_data = new Array();
        $(document).ready(function () {

            mui.init({
                pullRefresh: {
                    container: '#pullrefresh',
                    down: {
                        auto: true, // 首次进入自动加载
                        callback: pulldownRefresh
                    },
                    up: {
                        contentrefresh: '正在加载...',
                        callback: pullupRefresh
                    }
                }
            });

        })



        /**
         * 下拉刷新具体业务实现
         */
        function pulldownRefresh() {

            page = 1;
            var data = {
                id: id,
                page: page,
                limit: limit
            }
            getServerData(url_queryQuotationResult, data);
        }

        /**
         * 上拉加载具体业务实现
         */
        function pullupRefresh() {
            page++;
            var data = {
                id: id,
                page: page,
                limit: limit
            }
            getServerData(url_queryQuotationResult, data);
        }


        function getServerDataSuccess(url, data) {
            switch (url) {
                case url_queryQuotationResult:
                    var list = data.data;
                    var html_data = '';

                    if (list != null && list.length > 0) {
                        $.each(list, function (index, item) {

                            html_data += '<div class="margin-b-5">' +
                                '<div class="widget-default widget-body display-flex margin-b-1 padding-b-10 goJiGou" id="' + item.company.id + '" >' +
                                '<div class="position-img-l">' +
                                '<img src="' + (isEmpty(item.company.headPortrait) ? "../img/bg_default.png" : showSmallImg(item.company.headPortrait)) + '" alt="">' +
                                '<img src="../img/v.png" alt="">' +
                                '</div>' +
                                '<div class="display-flex flex-column margin-l-10 margin-t-f5">' +
                                '<p class="no-margin font-16 font-weight black1 elli1">' + item.company.userName + '</p>' +
                                '<div class="padding-t-5 padding-b-5">';
                            var types = '';
                            var i = 1;
                            $.each(item.company.serviceType, function (index, item) {
                                if (i <= 2) {
                                types += '<span class="tuli-content1 font-14 tuli-bg" style="margin-left:5px;">' + item.name + '</span>';
                                }
                                i++;

                            })

                            html_data += types +
                                '</div>' +
                                '<p class="font-12 gray no-margin line-height-18">' + (item.company.establishTime != null ? item.company.establishTime.substring(0, 10) : '') + '</p>' +
                                '<p class="font-12 gray no-margin line-height-18"> 地址：' + (item.company.addressDetail != null ? item.company.addressDetail : '') + '</p>' +
                                '</div>' +
                                '</div>' +
                                '<div class="text-right padding-10-15 widget-default">' ;
                                if(index == 0) {
                                    html_data += '<span class="tuli-content2 font-13 tuli-bg-b selectTa" id="' + (item.phone != null ? item.phone : '')   + '">' + '联系TA' + '</span>'
                                }

                 
             
                                html_data +='<span class="tuli-content2 font-13 view-quote"  id="' + item.id + '" ' +((index == 0)?('isTrue="true"'):'isTrue="false"')+'> 查看报价</span>' +
                                '</div>';
                            if (index == 0) {
                                $("#yiXuanZhong").html(html_data);
                                html_data = '';
                            }

                            index++;

                        })
                    }
                    if (page == 1) {
                        mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
                        if (list.length > 0) {
                            mui('#pullrefresh').pullRefresh().refresh(true);
                        }
                        $(".trade-list").html(html_data);
                    } else {
                        $(".trade-list").append(html_data);
                        mui('#pullrefresh').pullRefresh().endPullupToRefresh(list.length != limit);
                    }
                    break;


            }
        }

        function getServerDataFailed(url, data) {
            mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
            mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
        }

        
        
        mui("#yiXuanZhong").on('tap', '.view-quote', function () {
            
            var xuanZeId = $(this).attr("id");
            localStorage.setItem("view-quote-id",xuanZeId);
            localStorage.setItem("isTrue",$(this).attr("isTrue"));
            dsBridge.call("goViewQuote");
        });

        mui(".trade-list").on('tap', '.view-quote', function () {
            
            var xuanZeId = $(this).attr("id");
            localStorage.setItem("view-quote-id",xuanZeId);
            localStorage.setItem("isTrue",$(this).attr("isTrue"));
            dsBridge.call("goViewQuote");
        });
        
        
        mui("#yiXuanZhong").on('tap', '.goJiGou', function () {
            var xuanZeId = $(this).attr("id");
            localStorage.setItem('trainOrganizationId',xuanZeId);
            dsBridge.call("goJiGou");
        });

        mui("#yiXuanZhong").on('tap', '.selectTa', function () {
   
            dsBridge.call("callPhone",  $(this).attr("id"));
            
        });
        
    </script>

</body>

</html>